import { observable, action } from 'mobx';
import { ListAdvanced, RouteLayout } from 'weaver-mobile-page';
import * as Apis from "../../api/customerApis";

export default class ContactListRemindStore {
  comObj = {};
  params = {};

  @observable initResponsed = false;// 是否已经得到初始化数据的响应
  @observable initSuccessed = false;// 初始化数据是否获取成功
  @observable initFailedMsg = "";   // 初始化处理失败的原因
  @observable listAd = {};
  @observable detailLayout = {};
  @observable rowId = 0;

  @action
  doNew = (comObj, params) => {
    this.comObj = comObj;
    this.params = params;
    const route = comObj.props.match.path;
    this.listAd = new ListAdvanced.Store({ route: route, id: 'list' });
  }

  @action
  doInit = () => {
    this.doInitCallBack({});
  }

  @action
  doInitCallBack = (params) => {
    this.listAd.listViewStore.clearData();
    this.listAd.getData({ url: '/api/crm/contactLog/contactLogRemind', params: params });
    this.initResponsed = true;
    this.initSuccessed = true;
  }


  @action
  getList = () => {
    const params = this.listAd.searchParams;
    this.doInitCallBack(params);
  }

  @action
  doClear = () => {
    this.initResponsed = false;
    this.initSuccessed = false;
    this.initFailedMsg = "";
  }

  @action
  setRowId = (rowId) => {
    this.rowId = rowId;
    const route = this.comObj.props.match.path;
    this.detailLayout = new RouteLayout.Store({ route: route, id: rowId, init: 'true' });
    this.comObj.props.history.push(this.detailLayout.path);
  }
}